import cv2,requests # 调用网站接口本地测试
url = "http://localhost:8000/serviceApp/facedetect" # 本地测试localhost

# 上传图像并检测
tracker = None
imgPath = r'test\\face.jpg' # 图像路径
files = {"image":("filename2",open(imgPath,"rb"),"image/jpeg"),}
# 第9行返回json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
req = requests.post(url,data=tracker,files=files).json() #返回的请求数据转化为字符串
print("获取信息：{}".format(req))


# 将检测结果框显示在图像上
img = cv2.imread(imgPath)
for (w,x,y,z) in req["face"]:
    cv2.rectangle(img,(w,x),(y,z),(0,255,0),2)

cv2.imshow('face',img)
cv2.waitKey(0)